package listdemo;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: XMQ
 * Date: 2022-06-05
 * Time: 15:03
 */
//顺序表
public class MyArrayList {
    public int[] elem;
    public int DEFAULT_CAPACITY = 10;
    public int usedSize;

    //打印顺序表
    public void display(){
        for (int i = 0; i < usedSize; i++) {
            System.out.print(elem[i] + " ");
        }
        System.out.println();
    }

    //判断空间是否满了
    public boolean isFull(){
        if(DEFAULT_CAPACITY == elem.length){
            return true;
        }
        return false;
    }

    //增加数据 ->尾插
    public void add(int data){
        if(isFull()){
            elem = Arrays.copyOf(elem,DEFAULT_CAPACITY*2);
        }
        elem[usedSize++] = data;
    }

    //在pos位置上增加一个数据
    public void add(int pos, int data){

    }

    //删除数据  ->尾删
    public void del(){

    }
    //删除pos位置上的数据
    public void del(int pos){

    }

    public static void main(String[] args) {

    }
}
